package(default_visibility = ["//visibility:public"])

# TODO(jelbourn): figure out if these workarounds are still needed

# This rule belongs in node_modules/BUILD
# It's here as a workaround for
# https://github.com/bazelbuild/bazel/issues/374#issuecomment-296217940
filegroup(
  name = "node_modules",
  # Performance workaround: list individual files
  # Reduces the number of files as inputs to nodejs_binary:
  # bazel query "deps(:node_modules)" | wc -l
  # This won't scale in the general case.
  # TODO(alexeagle): figure out what to do
  srcs = glob(["/".join(["node_modules", pkg, "**", ext]) for pkg in [
    "@angular",
    "@angular-devkit",
    "@schematics",
    "@types",
    "bytebuffer",
    "hammerjs",
    "jasmine",
    "minimist",
    "moment",
    "parse5",
    "protobufjs",
    "protractor",
    "reflect-metadata",
    "rxjs",
    "tsickle",
    "tslib",
    "tslint",
    "typescript",
    "zone.js",
  ] for ext in [
    "*.js",
    "*.json",
    "*.d.ts",
  ]] + [
    "node_modules/http-server/**",
  ]),
)


# Glob pattern that matches all Angular testing bundles.
ANGULAR_TESTING = [
  "node_modules/@angular/*/bundles/*-testing.umd.js",
  # The compiler and the dynamic platform-browser should be visible only in tests
  "node_modules/@angular/compiler/bundles/*.umd.js",
  "node_modules/@angular/platform-browser-dynamic/bundles/*.umd.js",
]

filegroup(
  name = "angular_bundles",
  srcs = glob(["node_modules/@angular/*/bundles/*.umd.js"], exclude = ANGULAR_TESTING),
)

filegroup(
  name = "angular_test_bundles",
  testonly = 1,
  srcs = glob(ANGULAR_TESTING),
)

filegroup(
  name = "tslib_bundle",
  testonly = 1,
  srcs = glob(["node_modules/tslib/tslib.js"]),
)

# Files necessary for unit tests that use zonejs
filegroup(
  name = "web_test_bootstrap_scripts",
  # The order of these deps is important.
  # Do not sort.
  srcs = [
    "//:node_modules/reflect-metadata/Reflect.js",
    "//:node_modules/zone.js/dist/zone.js",
    "//:node_modules/zone.js/dist/zone-testing.js",
    "//:node_modules/zone.js/dist/task-tracking.js",
  ],
)
